<!--我的待办-->
<template>
  <div id="MyTodoList" ref="content">
    <!-- @load="onLoad" -->
    <div class="content">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了">
        <van-search background="#fff" v-model="value1" placeholder="请输入搜索关键词" @search="serachData" />
        <van-cell v-for="(item, index) in contentData" :key="index" v-if="item.NODE_NAME != '图集选用'">
          <ul>
            <li @click="contentClick(item)">
              <p style="font-weight: bold; margin-bottom: 8px; height: 3vh">
                <span style>{{ item.XM || item.HOUSEAPPLICANT }}</span>
                <span style="float: right">{{ item.NODE_NAME ? item.NODE_NAME : '村预审' }}</span>
              </p>
              <p style="font-size: 14px; color: #848484">
                <span style="float: left;width: 80vw;">申请编号:{{ item.LSH || '暂无数据' }}</span>
                <!-- <span style="float: right; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">地址:{{
                  item.HOMEADDRESS || item.ADDRESS }}</span> -->
              </p>
              <p style="font-size: 14px; color: #848484">
                <span style="float: left">申请时间:{{ item.APPLYTIME }}</span>
              </p>
              <p style="clear: both; display: flex; align-items: center">
                <img style="margin-right: 4px" width="10"
                  src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/YPC/dingwei.png" />
                <span style="font-size: 14px; color: blue">
                  {{ item.HOMEADDRESS || item.ADDRESS }}
                </span>
              </p>
            </li>
          </ul>
        </van-cell>
      </van-list>
      <!-- <ul>
        <li v-for="(item,index) 1in contentData" @click="contentClick(item)" :key="index">
          <p style="font-weight: bold;margin-bottom: 8px;">
            <span style="">{{item.name}}</span>
            <span style="float: right">{{item.name1}}</span>
          </p>
          <p style="font-size: 14px;color: #848484;">
            <span style="float: left">{{item.BH}}</span>
            <span style="float: right">{{item.time}}</span>
          </p>
          <p style="clear: both;display: flex;align-items: center;">
            <img style="margin-right: 4px;" width="10" src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/YPC/dingwei.png" />
            <span style="font-size: 0.08rem;color:blue">{{item.address}}</span>
          </p>
        </li>
      </ul>-->
    </div>
  </div>
</template>
<script>
import { QuerySignCallback } from '@/utils/api'
import BScroll from 'better-scroll'
import dd from 'gdt-jsapi'
import { Dialog } from 'vant'
export default {
  data() {
    return {
      loading: false,
      finished: false,
      contentData: [],
      value: '',
      value1: ''
    }
  },
  mounted() {
    this.$nextTick(() => {
      console.log(this.$refs.content, 'hezhilong')
      this.scroll = new BScroll(this.$refs.content, {})
    })
    dd.ready(function () {
      dd.setTitle({
        title: '我的待办'
      })
        .then((res) => { })
        .catch((err) => {
          console.error(err)
        })
    })
    this.getcontentData()
  },
  methods: {
    gotoMap(data) {
      // dd.ready(function () {
      //   dd.openLink({
      //     url: window.g.locateMapUrl+"?FWTYBH="+data.F_FWTYBH
      //   })
      //     .then(res => {
      //     })
      //     .catch(err => {
      //       console.error(err)
      //     })
      // })
      // let url = window.g.locateMapUrl + '?Address=' + data.PERMANENTADDR
      // if (data.PERMANENTADDR) {
      //   dd.ready(function () {
      //     dd.openLink({
      //       url: url,
      //     })
      //       .then((res) => {})
      //       .catch((err) => {
      //         window.open(url)
      //         console.error(err)
      //       })
      //   })
      // }
    },
    serachData(val) {
      debugger
      if (!val) return (this.contentData = this.shenkaobeiData)
      this.contentData = this.shenkaobeiData.filter((item) => {
        if (item.XM) {
          return item.XM && item.XM.indexOf(val) > -1
        } else {
          return item.HOUSEAPPLICANT && item.HOUSEAPPLICANT.indexOf(val) > -1

        }

      })
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.contentData.push(this.contentData.length + 1)
        }
        // 加载状态结束
        this.loading = false
        // 数据全部加载完成
        if (this.contentData.length >= 40) {
          this.finished = true
        }
      }, 1000)
    },
    getcontentData: async function (data) {
      this.contentData = []
      this.shenkaobeiData = []
      const function1 = async (dataguid) => {
        let params4 = {
          dataguid: dataguid,
          searchObject: this.value ? JSON.stringify([{ field: 'personname', value: this.value, operator: 'like' }]) : '[]',
          token: window.localStorage.getItem('token')
        }
        let params5 = {
          accessCode: '688bd3883572440a859dfd8ba9194e7b',
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          params: params4
        }
        const res4 = await QuerySignCallback(params5)
        // if(res4.data.data == '成功'){
        return JSON.parse(res4.data.data).Data
        // }
      }
      const p1 = Promise.all([
        function1('01103ebf-a884-4282-b996-78dd64196946'),
        function1('ca9e63d7-6f89-4125-80f8-d61aab3dfb01'),
        function1('931c475d-c6f3-41c0-8aef-28e20922db97'),
        function1('713761e1-74eb-4aec-8812-6b2e87fe3678')
      ])
      p1.then((res) => {
        console.log(res, 'hezhilong')
        res.forEach(item => {
          this.contentData.push(...item)
          this.shenkaobeiData.push(...item)
        })
        this.loading = true
        this.finished = true
        this.$nextTick(() => {
          this.scroll = new BScroll(this.$refs.content, {
            click: true,
            probeType: 3,
            pullUpLoad: true
          })
        })
      }).catch((err) => { })
    },
    onClickLeft() {
      this.$router.push({
        path: '/FeatureList'
      })
    },
    //建房审批自动批转到结束环节
    async autoSendTaskByJFSP(row) {
      let parms = {
        taskId: row.TASK_ID,
        direction: 0,
        wfGuid: row.WF_GUID,
        wfBoxGuid: '',
        sendNodes: JSON.stringify([
          {
            ISUSER: 0,
            PREJUNCNODEGUID: '',
            PTNID: -1,
            SINGLEASSIGN: true,
            TEXT: '审批结束',
            TNID: 1,
            WFNODEGUID: '{FEF0E7B0-F048-42E0-998E-06387B0D03DB}',
            WFNODENAME: '审批结束',
            WFNODETYPE: 6
          }
        ]),
        actionText: '同意',
        taskName: '浙里办'
      }
      let params10 = {
        accessCode: 'c52bcf7cf3fb42bb9fbcd9b91e97d411',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: parms
      }
      const res = await QuerySignCallback(params10)
      if (eval('(' + res.data.data + ')').Success == true) {
        this.$toast.success('发送成功!')
        this.getcontentData()
      } else {
        this.$toast.success('发送失败!')
      }
    },
    contentClick: async function (item) {
      debugger
      //区分新版和旧版 VERSIONNUMBER == 1 为新版  其余为旧版  item.VERSIONNUMBER == 1
      if (item?.VERSIONNUMBER == 1) {
        console.log(item)
        if (item.ISDELETE == 12) {
          this.$router.push({
            path: '/writeOff',
            query: { data: JSON.stringify(item) }
          })
          return
        }
        if (item.ISDELETE == 13) {
          this.$toast.fail('该件已注销!')
          return
        }
        if (item.NODE_GUID === '{67241083-CA60-43FC-B1C1-1F4A2D133184}' || item.NODE_GUID == '{5E1AD806-7824-4196-8ADF-E231A8704FD3}' || item.NODE_GUID == '{4BF99B6A-E6EE-4A47-B3AE-B9CD2DBD1F3E}') {
          //现场踏勘
          this.$router.push({
            path: '/siteSurveynew',
            query: { data: JSON.stringify(item) }
          })
        } else if (
          item.NODE_GUID == '{5821E9EB-44B5-49AC-A659-6DF98B410B38}' ||
          item.NODE_GUID == '{0439EC7A-785D-4B5B-ADD4-11E2D320376E}' ||
          item.NODE_GUID == '{417EFF61-5FA8-44D6-A624-5B3D0F39B56C}' ||
          item.NODE_GUID == '{777D7530-351F-4BAA-8A28-9153C53A4BBE}' ||
          item.NODE_GUID == '{97E3145A-01B9-4CEE-AA4E-21CA9F0FF671}' ||
          item.NODE_GUID == '{299D1B2C-4EDA-4963-AC66-E91B3403A49E}' ||
          item.NODE_GUID == '{9766D96E-8B85-481F-B514-C0B21CF4DC3A}'
        ) {
          //三方经办人、负责人界面(新)
          this.$router.push({
            path: '/ThreeJingBanRen',
            query: { data: JSON.stringify(item) }
          })
        }
        //新版v2 批前公示
        else if (item.NODE_GUID == '{342312E7-E3BC-426A-8568-E5E4EDD94A1A}') {
          this.$router.push({
            path: '/piqianGSNew',
            query: { data: JSON.stringify(item), ispqgs: 1 }
          })
        }
        //打印相关报表、盖章
        else if (item.NODE_GUID == '{B8C0E603-AB3B-4FA6-BC92-21D4F393CC28}') {
          Dialog.confirm({
            title: '提示',
            message: '如需<打印相关报表、盖章>请前往粤政易业务系统进行打印！提交后建房审批流程将结束,是否继续提交?',
            confirmButtonText: '确定',
            cancelButtonText: '取消'
          })
            .then(() => {
              //自动批准结束
              this.autoSendTaskByJFSP(item)
            })
            .catch(() => { })
        }

        //  else if (item.NODE_GUID == '{BFF3BE52-75D4-4C53-B5E9-9144E35E7617}') {
        //   //现场放养
        //   this.$router.push({
        //     path: '/oneLayerForm',
        //     query: { data: JSON.stringify(item) }
        //   })
        // }
        else if (item.NODE_GUID == '{34A96C75-DF0E-4781-BA03-0F17FDD5B062}') {
          //批前公示
          this.$router.push({
            path: '/piqianGS',
            query: { data: JSON.stringify(item), ispqgs: 1 }
          })
        } else if (!item.NODE_GUID || item.NODE_GUID == '{A0C5F07B-1947-452D-942B-81D8A2095EBA}') {
          //判断是否是村预审
          this.$router.push({
            path: '/ceshi',
            query: { data: JSON.stringify(item) }
          })
        } else if (item.NODE_GUID == '{646A4D45-00AC-4EA9-98AE-C5E704740BC1}') {
          //镇街定位放样(新)
          this.$router.push({
            path: '/siteSettingOut',
            query: { data: JSON.stringify(item) }
          })
        } else if (item.NODE_GUID == '{D9C76DDF-7A07-4F5F-A9F2-FD597C715481}') {
          //基槽验线V2
          this.$router.push({
            path: '/siteSettingOut',
            query: { data: JSON.stringify(item) }
          })
        } else if (item.NODE_GUID === '{BFF3BE52-75D4-4C53-B5E9-9144E35E7617}') {
          //一层立模镇街审核(新)
          this.$router.push({
            path: '/siteSettingOut',
            query: { data: JSON.stringify(item) }
          })
        } else if (
          item.NODE_GUID == '{5CC13346-8C53-4A37-989D-932716248754}' ||
          item.NODE_GUID == '{EB7D42FE-320C-4A0A-9C98-3E9373898826}' ||
          item.NODE_GUID == '{74864380-8590-4F8B-BD75-942E08F04D81}' ||
          item.NODE_GUID == '{003E7696-65E6-432B-97A7-C95711D1D0E0}' ||
          item.NODE_GUID == '{DDCED543-65DD-4D6B-BEFC-B07DBDDA6C76}' ||
          item.NODE_GUID == '{38E4E7DB-963D-40F1-B1E1-FF8793AD23AD}' ||
          item.NODE_GUID == '{41EE42C1-2F52-45C5-A05C-D2D3160DCE23}'
        ) {
          //竣工验收 三方经办人  三方负责人
          this.$router.push({
            path: '/compleAcceptance',
            query: { data: JSON.stringify(item) }
          })
        } else if (item.NODE_GUID == '{C1C592F3-63AE-4206-8382-A7D695ED2DF6}') {
          //住房和城乡建设主管部门备案
          this.$router.push({
            path: '/departmentalFiling',
            query: { data: JSON.stringify(item) }
          })
        }

        return
      }
      if (item.NODE_GUID === '{67241083-CA60-43FC-B1C1-1F4A2D133184}' || item.NODE_GUID == '{5E1AD806-7824-4196-8ADF-E231A8704FD3}' || item.NODE_GUID == '{4BF99B6A-E6EE-4A47-B3AE-B9CD2DBD1F3E}') {
        //现场踏勘
        this.$router.push({
          path: '/Sitesurvey',
          query: { data: JSON.stringify(item) }
        })
        // this.$router.push({
        //   path: '/siteSurveynew',
        //   query: { data: JSON.stringify(item) }
        // })
      } else if (item.NODE_GUID == '{34A96C75-DF0E-4781-BA03-0F17FDD5B062}' || item.NODE_GUID == '{342312E7-E3BC-426A-8568-E5E4EDD94A1A}') {
        //批前公示
        this.$router.push({
          path: '/piqianGS',
          query: { data: JSON.stringify(item), ispqgs: 1 }
        })
      } else if (item.NODE_GUID === '{9766D96E-8B85-481F-B514-C0B21CF4DC3A}') {
        //乡镇人民政府审核
        this.$router.push({
          path: '/ZFSHXXB',
          query: { data: JSON.stringify(item) }
        })
      } else if (item.NODE_GUID === '{417EFF61-5FA8-44D6-A624-5B3D0F39B56C}') {
        //  资格审核经办人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '资格审核经办人'
          }
        })
      } else if (item.NODE_GUID === '{299D1B2C-4EDA-4963-AC66-E91B3403A49E}') {
        //  资格审核负责人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '资格审核负责人'
          }
        })
      } else if (item.NODE_GUID === '{0439EC7A-785D-4B5B-ADD4-11E2D320376E}') {
        //  规划审核经办人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '规划审核经办人'
          }
        })
      } else if (item.NODE_GUID === '{97E3145A-01B9-4CEE-AA4E-21CA9F0FF671}') {
        //  规划审核负责人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '规划审核负责人'
          }
        })
      } else if (item.NODE_GUID === '{5821E9EB-44B5-49AC-A659-6DF98B410B38}') {
        //  农房审核经办人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '农房审核经办人'
          }
        })
      } else if (item.NODE_GUID === '{777D7530-351F-4BAA-8A28-9153C53A4BBE}') {
        //  农房审核负责人
        this.$router.push({
          path: '/HandlerPage',
          query: {
            data: JSON.stringify(item),
            type: '农房审核负责人'
          }
        })
      } else if (
        (item.WF_GUID == '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}' && item.NODE_GUID == '{646A4D45-00AC-4EA9-98AE-C5E704740BC1}') ||
        (item.WF_GUID == '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}' && item.NODE_GUID == '{D9C76DDF-7A07-4F5F-A9F2-FD597C715481}') ||
        (item.WF_GUID == '{7F042B34-7091-4884-A5D6-A615AE55497D}' && item.NODE_GUID == '{BFF3BE52-75D4-4C53-B5E9-9144E35E7617}')
      ) {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: item.PROC_NAME
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{41EE42C1-2F52-45C5-A05C-D2D3160DCE23}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: item.PROC_NAME
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{5CC13346-8C53-4A37-989D-932716248754}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '资格经办人'
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{EB7D42FE-320C-4A0A-9C98-3E9373898826}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '资格负责人'
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{74864380-8590-4F8B-BD75-942E08F04D81}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '规划经办人'
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{003E7696-65E6-432B-97A7-C95711D1D0E0}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '规划负责人'
          }
        })
      }
      // ******8
      else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{7C289E35-88FC-4002-9B88-ED6F472CA872}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '农房经办人'
          }
        })
      } else if (item.WF_GUID == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}' && item.NODE_GUID == '{B6D1F2A1-ACF3-4894-948E-54B9BC1F059F}') {
        this.$router.push({
          path: '/SidaochangPage',
          query: {
            data: JSON.stringify(item),
            type: '镇街审核',
            name: '农房负责人'
          }
        })
      } else if (item.WF_GUID == '{9FF1C524-B55F-4A45-83B3-6EA46CF32092}' && item.NODE_GUID == '{FAFEF7FF-6294-489A-A5DF-53906712EBEE}') {
        this.$router.push({
          path: '/KeyLine',
          query: { PROC_GUID: item.PROC_GUID }
        })
      } else if (
        item.NODE_GUID == '{22FD5C82-A491-420C-8F1B-5EBDDE0EC5FE}' ||
        item.NODE_GUID == '{0493F00B-6F0A-4E14-9315-9DF68EE6E755}' ||
        item.NODE_GUID == '{7D278D07-FEEB-410B-8319-1D0C85B10890}'
      ) {
        this.$router.push({
          path: '/EnterpriseUnitReview',
          query: { data: JSON.stringify(item) }
        })
      } else if (item.NODE_GUID == '{A0C5F07B-1947-452D-942B-81D8A2095EBA}' || item.SBZT == '已提交') {
        this.$router.push({
          path: '/Villagetrial',
          query: { data: JSON.stringify(item) }
        })
      } else if (item.NODE_GUID == '{BF5EBF92-26ED-46F4-A7E5-EFFDD7C8BE0C}') {
        this.$router.push({
          path: '/countryPublicity',
          query: { data: JSON.stringify(item) }
        })
      } else if (item.NODE_GUID !== '{A0C5F07B-1947-452D-942B-81D8A2095EBA}' || item.SBZT !== '已提交') {
        this.$toast.fail('该环节请转至浙里办处理！')
      }
    }
  }
}
</script>
<style lang="scss" scoped>
#MyTodoList {
  height: 100vh;
  //   overflow: auto;
  background: #eee;
  font-size: 16px;
  overflow: hidden;

  .content {

    // height: 100vh;
    // overflow: auto;
    // padding: 10px;
    ul li {
      background-color: white;
      // margin: 14px 10px;
      border-radius: 10px;
      padding: 10px;
      width: 100%;
      margin: 0 auto;
      margin-top: 6px;
      color: black;
      box-shadow: 0 0 12px #e3e3e3;
    }
  }
}
</style>

<style>
#MyTodoList .van-cell {
  background-color: #eee !important;
  padding: 4px 10px;
}
</style>
